package com.ruoyi.scrb.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.scrb.domain.ScrbScc;
import com.ruoyi.scrb.service.IScrbSccService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生产处生产日报录入Controller
 * 
 * @author wy
 * @date 2022-10-07
 */
@RestController
@RequestMapping("/scrb/scc")
public class ScrbSccController extends BaseController
{
    @Autowired
    private IScrbSccService scrbSccService;

    /**
     * 查询生产处生产日报录入列表
     */
    @PreAuthorize("@ss.hasPermi('scrb:scc:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScrbScc scrbScc)
    {
        startPage();
        List<ScrbScc> list = scrbSccService.selectScrbSccList(scrbScc);
        return getDataTable(list);
    }

    /**
     * 导出生产处生产日报录入列表
     */
    @PreAuthorize("@ss.hasPermi('scrb:scc:export')")
    @Log(title = "生产处生产日报录入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScrbScc scrbScc)
    {
        List<ScrbScc> list = scrbSccService.selectScrbSccList(scrbScc);
        ExcelUtil<ScrbScc> util = new ExcelUtil<ScrbScc>(ScrbScc.class);
        util.exportExcel(response, list, "生产处生产日报录入数据");
    }

    /**
     * 获取生产处生产日报录入详细信息
     */
    @PreAuthorize("@ss.hasPermi('scrb:scc:query')")
    @GetMapping(value = "/{cDate}")
    public AjaxResult getInfo(@PathVariable("cDate") String cDate)
    {
        return AjaxResult.success(scrbSccService.selectScrbSccByCDate(cDate));
    }

    /**
     * 新增生产处生产日报录入
     */
    @PreAuthorize("@ss.hasPermi('scrb:scc:add')")
    @Log(title = "生产处生产日报录入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScrbScc scrbScc)
    {
        return toAjax(scrbSccService.insertScrbScc(scrbScc));
    }

    /**
     * 修改生产处生产日报录入
     */
    @PreAuthorize("@ss.hasPermi('scrb:scc:edit')")
    @Log(title = "生产处生产日报录入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScrbScc scrbScc)
    {
        return toAjax(scrbSccService.updateScrbScc(scrbScc));
    }

    /**
     * 删除生产处生产日报录入
     */
    @PreAuthorize("@ss.hasPermi('scrb:scc:remove')")
    @Log(title = "生产处生产日报录入", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cDates}")
    public AjaxResult remove(@PathVariable String[] cDates)
    {
        return toAjax(scrbSccService.deleteScrbSccByCDates(cDates));
    }
}
